vulkan: disable MMVQ on AMD UMA devices#24966
Conversation
MMVQ's quantization overhead outweighs bandwidth savings on UMA where CPU and GPU share the same memory pool.
|
Your benchmark is invalid, you don't even show the baseline. FORCE_MMVQ enables it anywhere, which is not default behaviour. Also, here's a counter example on AMD Strix Halo: before is just base master, after is with
|
|
Yes It was a very quick way to test. After testing with several model I found that the performance was not as prominent. It might due to the thermal behavior my laptop. Benchmark on the patchTo isolate the behavior, I profiled the changes using a benchmark script that measures the performance impact of MMVQ (Matrix-Matrix-Vector Quantization) during matrix multiplication operations (MUL_MAT). Below is the summary of the benchmark run on my AMD UMA device (using the maximum GFLOPS over 4 warm repeats, skipping 1 cold burn-in): SUMMARY (max GFLOPS of 4 warm repeats, 1 cold burn-in skipped)
Key Observations:
OverallFollowing the isolated benchmarks, I tested several real-world models to evaluate the end-to-end impact of the patch during single-token generation (tg128, not using flags):
Given that AMD UMA hardware can be highly sensitive to background noise, thermal behavior, and initial shader compilation overhead (especially if the Vulkan pipeline cache isn't warmed up, that also happen to me during the benchmark setup). Could you try running a re-test again? |
|
And you think I'm not aware of thermal behaviour? llama-bench does multiple runs for that reason, at most you see a higher variance. With your latest results you didn't even show whether you used FORCE_MMVQ or not. Regardless, a blanket disable on UMA devices makes no sense, and you should really not be using claude to try to explain the reason for performance behaviour, it is guaranteed to hallucinate. |
Sometime I saw the tg values are not consistent from run to run (low variance). Thus sometime I need to run several times to verify the change
I am not using flags in the above benchmark result
I tested the benchmark using k=28672 (Llama 3.1 70B) and 53248 (Llama 3.1 405B)
Due to the lack of a dedicated Q6_K MMVQ compute shader, current Q6_K MMVQ performance falls behind Q2_K MMVQ, Q4_K MMVQ, and non-MMVQ Q6_K execution path. I believe that implementing a dedicated Q6_K MMVQ shader would close this gap, bringing the performance of the MMVQ-enabled and disabled paths very close to parity. Additionally, performance regressions become noticeable on the Q8_0 path once the matrix inner dimension hits Therefore I would suggest adding the max k to 28672 to avoid any regression
Agree. Further cross-check is needed. Also I am not sure if it is hallucinate but after searching I guess the suggestion comes from this discussion But AI models write better than me that is no doubt |
MMVQ's quantization overhead outweighs bandwidth savings on UMA where CPU and GPU share the same memory pool.
Overview
This is the testing result before the patch is written (tested on AMD UMA only):
tg value jump from 28.78 to 30.79 on my device.
The patch is applied to AMD path because this is the device that I could test.
Additional information
The following explanation is written by Claude:
The MMVQ path quantizes the input vector to Q8_1 before dispatching, which adds CPU-side work and an extra quantization kernel on the GPU. On a discrete GPU with fast VRAM, that overhead is worth it because it reduces the weight-loading bandwidth. On my AMD UMA device, the CPU and GPU share the same LPDDR5X pool — the quantization step costs real time and the bandwidth savings are smaller because my device is already memory-bandwidth-limited from both sides simultaneously.
The effectiveness of the patch depends on how much time each model actually spends in these kernels relative to everything else:
Based on the test I see that this patch would
Requirements